function Cursor(x, y, r, color)
{
	this.x = x;
	this.y = y;
	this.radius = r;
	this.color = color;
	this.mapX = this.SetMapPos();
	this.mapY = 0;
	this.offsetX = 0;
	this.offsetY = 0;
	this.goLeft = true;
	this.goRight = true;
	this.gameover = false;
}

Cursor.prototype.DrawCursor = function()
{
	context1.beginPath();
    context1.arc(this.x, this.y, this.radius, 0, 2 * Math.PI, false);
 
    context1.fillStyle = this.color;
    context1.fill();
    context1.lineWidth = 5;
}

Cursor.prototype.SetMapPos = function()
{
	var mapX = Math.floor(this.x / 100);
	return mapX;
	
}
Cursor.prototype.MoveCursor = function()
{
	if(this.mapX < numberOfNode 
		&& this.mapY < numberOfCP 
		&& this.gameover == false)
	{
		if(cp[this.mapX][this.mapY].start == true 
			&& cp[this.mapX+1][this.mapY].end == true 
			&& this.goRight == true)
		{
			this.x++;
			this.offsetX++;
			if(this.offsetX >= 100)
			{
				this.offsetX = 0;
				this.mapX++;
				this.goRight = false;
				this.goLeft = false;
				//this.x = cp[this.mapX][this.mapY].pos.X;
			}		
		}	
		else if(cp[this.mapX][this.mapY].end == true 
			&& cp[this.mapX-1][this.mapY].start == true
			&& this.goLeft == true)
		{
			this.x--;
			this.offsetX++;
			if(this.offsetX >= 100)
			{
				this.offsetX = 0;
				this.mapX--;
				this.goLeft = false;
				this.goRight = false;
				//this.x = cp[this.mapX][this.mapY].pos.X;
			}		
		}
		else
		{
			this.y++;
			this.offsetY++;
			if(this.offsetY >= 40)
			{
				this.offsetY = 0;
				this.mapY++;
				this.goRight = true;
				this.goLeft = true;
				
			}
		}	
	}
	if(this.mapY >= numberOfCP)
	{
		this.gameover = true;
		//alert("end");
	}
}
